package com.hongyun.tms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hongyun.tms.common.dto.tug.TmsMTugQueryDto;
import com.hongyun.tms.entity.PordWork;
import com.hongyun.tms.entity.TmsMTug;
import com.hongyun.tms.mapper.FirstPageMapper;
import com.hongyun.tms.service.FirstPageService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;

/**
 * 拖轮信息表
 *
 * @author yuheng
 * @since 1.0.0 2024-06-06
 */
@Service
public class FirstPageServiceImpl extends ServiceImpl<FirstPageMapper, HashMap> implements FirstPageService {

    public HashMap<String, BigDecimal> getPlanNum(String planDte){
        String planMon = planDte.substring(0,7);
        return baseMapper.getPlanNum(planDte,planMon);
    }


    private LambdaQueryWrapper<TmsMTug> getWrapper(TmsMTugQueryDto query) {
        LambdaQueryWrapper<TmsMTug> wrapper = Wrappers.lambdaQuery();
        wrapper.like(StringUtils.isNotBlank(query.getTugName()), TmsMTug::getTugName, query.getTugName())
                .like(StringUtils.isNotBlank(query.getCallNo()), TmsMTug::getCallNo, query.getCallNo())
                .eq(query.getStaus() != null, TmsMTug::getStaus, query.getStaus())
                .eq(StringUtils.isNotBlank(query.getTugTypeCode()), TmsMTug::getTugTypeCode, query.getTugTypeCode())
                .eq(StringUtils.isNotBlank(query.getPortAreaCode()), TmsMTug::getPortAreaCode, query.getPortAreaCode())
                .orderByDesc(TmsMTug::getBuildDate);
        return wrapper;
    }

    @Override
    public List<HashMap<String, Object>> getWorkItemGroup(String planDte){
        planDte=planDte.substring(0,4);
        return baseMapper.getWorkItemGroup(planDte);
    }
    @Override
    public List<HashMap<String, Object>> getFeeList() {
        return baseMapper.getFeeList();
    }
    @Override
    public List<TmsMTug> getTmsMTug() {
        return baseMapper.getTmsMTug();
    }
    public List<PordWork> getWorkByTmsMTug(String id) {
        return baseMapper.getWorkByTmsMTug(id);
    }

    @Override
    public List<HashMap<String, Object>> getConsumeTmsMTug() {
        return baseMapper.getConsumeTmsMTug();
    }
}
